/**
 * 参考：https://router.vuejs.org/zh/guide/
 */
import { createRouter, createWebHashHistory } from 'vue-router'

// 导入对应的页面
import NewsList from '../views/NewsList.vue'
import FoodsList from '../views/FoodsList.vue'
import NewsDetail from '../views/NewsDetail.vue'
import FoodDetail from '../views/FoodDetail.vue'
import NotFound from '../views/NotFound.vue'

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    { path: '/newslist', component: NewsList },
    { path: '/foodlist', component: FoodsList },
    { path: '/', redirect: '/newslist' },

    { path: '/newsdetail', component: NewsDetail },
    { path: '/fooddetail/:id/:name', component: FoodDetail },

    // Vue2中路由配置这样写没问题
    // { path: '*', component: NotFound }
    // { path: '/:pathMatch(.*)*', component: NotFound }
    { path: '/:pathMatch(.*)', component: NotFound }
  ]
})

export default router
